Conversation
* also initialize vite.config.js during compile, in case user has set a different runtime frontend path * remove assetsDir workaround (base handles this case)
Add `prepend_frontend_path` to `rx.Config` to make it easy to handle the contract in current and future APIs. Use `prepend_frontend_path` in: * rx.get_upload_url * rx.asset * vite config * react router config
Greptile SummaryThis PR fixes Confidence Score: 5/5Safe to merge — all remaining findings are P2 style/edge-case items that don't affect any realistic user configuration. Both findings are P2: a commented-out decorator (style/rule violation) and a double-slash edge case in packages/reflex-base/src/reflex_base/config.py — the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[frontend_path config\ne.g. '/prefix'] --> B[prepend_frontend_path\nConfig method]
B --> C[Vite config\nbase: '/prefix/']
B --> D[React Router\nbasename: '/prefix/']
B --> E[Starlette Mount\n'/prefix/']
B --> F[rx.asset local\n'/prefix/image.png']
B --> G[rx.asset shared\n'/prefix/external/...']
B --> H[AppHarnessProd\n404 path + frontend_url]
C --> I[Vite builds assets\nwith correct public URLs]
D --> J[Client-side nav\nstays under /prefix]
E --> K[Static file server\nserves from /prefix]
F & G --> L[Asset URLs\nresolvable by browser]
H --> M[Test harness\nserves 404.html correctly]
Reviews (2): Last reviewed commit: "fix frontend path for shared assets" | Re-trigger Greptile |
playwright uses a session scope fixture which creates an event loop for the session, so subsequent tests using pytest_asyncio fixture cannot start their own loop and fail
include updated test case
|
@greptile-apps re-review this PR |
Summary
Fixes outstanding issues with the
frontend_pathconfig option and adds comprehensive integration tests to prevent regressions.When
frontend_pathis set (e.g.frontend_path="/app"), the Reflex app is served from a subpath instead of the root. This PR ensures that assets, stylesheets, links, redirects, uploads,on_loadevents, and 404 pages all work correctly under a configuredfrontend_path.Changes
tests/integration/tests_playwright/test_frontend_path.py): Comprehensive playwright tests covering links (static and dynamic routes), redirects (event handler andon_load), assets (local and shared), uploaded files (rx.get_upload_url), CSSurl()references,on_loadevent firing, and 404 pages. Tests are parametrized over dev/prod mode and with/withoutfrontend_path.reflex/assets.py):rx.asset(shared=True)now callsprepend_frontend_pathon its return value, matching the existing behavior for local assets.testing.py: FixAppHarnessProdto locate404.htmlunder thefrontend_pathsubdirectory when set, matching real prod deployment behavior..github/workflows/integration_app_harness.yml): Run playwright tests in a separate job from other integration tests. Thepytest-playwrightplugin keeps an asyncio event loop running on the main thread for the session, which is incompatible withpytest-asynciotests in the same process.Closes
Supersedes
Test plan
uv run pytest tests/integration/tests_playwright/test_frontend_path.py -vpasses in both dev and prod modes, with and withoutfrontend_pathuv run pytest tests/integration --ignore=tests/integration/tests_playwright -v